﻿using System.Xml;

namespace BuzzX8.Xmpp.DataForms
{
    public class Option : StreamElement
    {
        public Option() : base("option")
        {}

        public Option(string name, object value) :this()
        {
            OptionName = name;
            Value = value;
        }

        public string OptionName
        {
            get { return Attributes["label"] as string; }
            set { Attributes["label"] = value; }
        }

        public object Value { get; set; }

        protected override void WritePayload(XmlWriter writer)
        {
            base.WritePayload(writer);
            WriteValue(writer);
        }

        private void WriteValue(XmlWriter writer)
        {
            if (Value != null) writer.WriteElementString("value", Value.ToString());
        }
    }
}
